package com.example.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.user_infoModel;
import com.example.service.UserService;
import com.github.pagehelper.PageHelper;

@Controller
public class UserController {
	@Resource
	private UserService userService;
	
	@RequestMapping("/adduser")
	@ResponseBody
	public user_infoModel get(){
		user_infoModel u = new user_infoModel();
		u.nickname="hahah";
		u.token="123";
		u.account_number="17315031651";
		userService.save(u);
		System.err.println(u);
		return u;
	}
	
	@RequestMapping("/getuser")
	@ResponseBody
	public Iterable<user_infoModel> listUser(){
		Iterable<user_infoModel> list = userService.list();
		return list;
	}
	
	@RequestMapping("/getuser/mybatis")
	@ResponseBody
	public List<user_infoModel> listUser_mybatis(){
		PageHelper.startPage(2, 2);
		return userService.getAllUser();
	}
	
	@RequestMapping("/getuser/mybatis/{name}")
	@ResponseBody
	public List<user_infoModel> getUserByName(@PathVariable String name){
		return userService.getUserByName(name);
	}
}
